package cn.tedu.second;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test01 {
    @Test
    public void test01(){
        //byType 报出异常UnsatisfiedDependencyException
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        Context context = (Context) applicationContext.getBean("context");
        System.out.println(context);
        ((ClassPathXmlApplicationContext)applicationContext).close();
    }
    @Test
    public void test02(){
        //byName 报出异常BeanDefinitionParsingException
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        Context context = (Context) applicationContext.getBean("context");
        System.out.println(context);
        ((ClassPathXmlApplicationContext)applicationContext).close();
    }

}
